package com.gupao.edu.study.singleton;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Author: guqy
 * @Description: 注册式单例
 * @Date 10:41 2018/3/19
 */
public class Register {
    /**
     * 私有化构造
     */
    private Register(){}
    private static Map map = new ConcurrentHashMap();

    public Register getInstance(String name) {
        if (name == null || ("").equals(name)) {
            name = Register.class.getName();
        }

        if (map.get(name) == null) {
            map.put(name, new Register());
        }
        return (Register) map.get(name);
    }
}
